#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/wait.h>
int main(){
  pid_t id = fork();
  if(id<0){
    perror("fork error!\n");
    return 1;
  }
  if(id==0){
    //child
    
    char* const argv[] = {"ls","-a","-l",NULL};
    char* const envp[] = { "PATH=/bin:/usr/bin", "TERM=console", NULL };
    //execl("/usr/bin/ls" , "ls", "-l" ,"-a",NULL);
    //execlp("ls","ls", "-l" ,"-a",NULL);
    execl("./myproc","myproc",NULL);
    //execv("/usr/bin/ls",argv);
    //execvp("ls",argv);
    //execve("/usr/bin/ls",argv,envp);
    //
    printf("exec filed!\n");
    exit(0);
  }

  pid_t ret = wait(NULL);
  if(ret<0){
    printf("wait filed!\n");
  }
  printf("wait success!\n");
  return 0;
}
